home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / demo / server / scripts / triggers.cs < prev    next >
Encoding:
Text File  |  2005-11-23  |  2.1 KB  |  53 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6. //-----------------------------------------------------------------------------
  7. // DefaultTrigger is used by the mission editor.  This is also an example
  8. // of trigger methods and callbacks.
  9.  
  10. datablock TriggerData(DefaultTrigger)
  11. {
  12.    // The period is value is used to control how often the console
  13.    // onTriggerTick callback is called while there are any objects
  14.    // in the trigger.  The default value is 100 MS.
  15.    tickPeriodMS = 100;
  16. };
  17.  
  18.  
  19. //-----------------------------------------------------------------------------
  20.  
  21. function DefaultTrigger::onEnterTrigger(%this,%trigger,%obj)
  22. {
  23.    // This method is called whenever an object enters the %trigger
  24.    // area, the object is passed as %obj.  The default onEnterTrigger
  25.    // method (in the C++ code) invokes the ::onTrigger(%trigger,1) method on
  26.    // every object (whatever it's type) in the same group as the trigger.
  27.    Parent::onEnterTrigger(%this,%trigger,%obj);
  28. }
  29.  
  30. function DefaultTrigger::onLeaveTrigger(%this,%trigger,%obj)
  31. {
  32.    // This method is called whenever an object leaves the %trigger
  33.    // area, the object is passed as %obj.  The default onLeaveTrigger
  34.    // method (in the C++ code) invokes the ::onTrigger(%trigger,0) method on
  35.    // every object (whatever it's type) in the same group as the trigger.
  36.    Parent::onLeaveTrigger(%this,%trigger,%obj);
  37. }
  38.  
  39. function DefaultTrigger::onTickTrigger(%this,%trigger)
  40. {
  41.    // This method is called every tickPerioMS, as long as any
  42.    // objects intersect the trigger. The default onTriggerTick
  43.    // method (in the C++ code) invokes the ::onTriggerTick(%trigger) method on
  44.    // every object (whatever it's type) in the same group as the trigger.
  45.  
  46.    // You can iterate through the objects in the list by using these
  47.    // methods:
  48.    //    %this.getNumObjects();
  49.    //    %this.getObject(n);
  50.    Parent::onTickTrigger(%this,%trigger);
  51. }
  52.  
  53.